/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package info.touret.winecellar.reminder;

import info.touret.winecellar.userinfo.server.UserInfoFactoryImpl;
import info.touret.winecellar.userinfo.server.domain.UserInfo;

import org.apache.log4j.Logger;

import com.google.appengine.api.utils.SystemProperty;
import com.google.appengine.api.utils.SystemProperty.Environment.Value;
import com.google.gdata.client.calendar.CalendarService;
import com.google.inject.AbstractModule;

/**
 * 
 * @author touret-a
 */
public class ReminderModule extends AbstractModule {
	private static Logger trace = Logger.getLogger(ReminderModule.class);

	private UserInfo userinfo ;
	
	
	
	public UserInfo getUserinfo() {
		return userinfo;
	}



	public void setUserinfo(UserInfo userinfo) {
		this.userinfo = userinfo;
	}



	@Override
	protected void configure() {
		trace.info("Configuration des reminders google calendar");
		SystemProperty.environment.value();
		bind(UserInfo.class).toInstance(getUserinfo());
		trace.error("Bind to "+getUserinfo());
		if (SystemProperty.environment.value().equals(
				Value.Production)) {
			trace.info("Ajout de la gestion des reminders pour l environnenemnt de production");
			bind(CalendarService.class).toProvider(
					GAECalendarServiceFactory.class);
		} else {
			trace.info("Ajout de la gestion des reminders pour l environnenemnt de dev");
			bind(CalendarService.class).toProvider(
					LocalCalendarServiceFactory.class);
		}
		bind(ReminderService.class).to(ReminderServiceImpl.class);
	}
}